package com.songqintuan.common.dal.ibatis.basedao;

import java.io.Serializable;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.songqintuan.common.bean.Page;

public interface IIbatisDao<T, PK extends Serializable> {
	
	public abstract void setEntityClass(Class<T> entity);
	
	/**
	 * 设置主码类型
	 * @param type
	 */
	public abstract void setPKClass(Class<PK> pk);

	public T findById(PK id) throws Exception, Exception;
	
	public List<T> findByIds(List<PK> ids) throws Exception, Exception;
	
	public List<T> getAll() throws Exception ;
	
	public void insert(T o) throws Exception;
	
	public int update(T o) throws Exception;
	
	public int delete(T o) throws SQLException;
	
	public int deleteById(PK id) throws SQLException;
	
	public List<T> find(Map<String, Object> map) throws Exception;
	
	public List<T> findBy(String property, Object value) throws Exception;
	
	public T findUniqueByMap(Map<String, Object> map) throws Exception;
	
	public T findUniqueBy(String name, Object value);
	
	public List<T> findByLike(String name, String value) throws Exception;
	
	public Page<T,PK> pagedQuery(String sqlName, HashMap<String, Object> hashMap, Integer pageNo, Integer pageSize) throws Exception;
	
	public Page<T,PK> pagedQuery(String sqlName, String[] properties, Object[] propertyValues, Integer pageNo, Integer pageSize) throws Exception;
	
	public Integer count(String propertyName, Object propertyValue) throws SQLException, Exception;
	
	public Integer countLikeByMap(String[] propertyNames, Object[] propertyValues) throws Exception, Exception;
	
	public void deleteByIdsMap(List<PK> ids, String[] properties, Object[] propertyValues) throws Exception;
	
	public int deleteByMap(String[] properties, Object[] propertyValues) throws Exception;
	
	public int update(PK id, String[] properties, Object[] propertyValues) throws Exception;
	
	public int updateByIdsMap(List<PK> ids,String[] properties, Object[] propertyValues) throws Exception;

}
